/*
 * Script to generate and react to addChoice requests
 * and responses
 * 
 * Author: Chris Casola
 */

/**
 * Function to handle an addChoice response
 */
function handleAddChoiceResponse(response) {
	if (response.success == "true") {
		var choiceResponse = response.addChoiceResponse;
		window.dlEvent.setChoiceLabel(choiceResponse.choice, choiceResponse.number);
		var choiceList = document.getElementById('choiceList');
		var newChoiceLi = document.createElement('li');
		newChoiceLi.innerHTML = choiceResponse.choice;
		choiceList.appendChild(newChoiceLi);
	}
	else {
		alert("Unable to add choice!");
	}
	
	if ((window.dlEvent.state == 1) && (window.currentForm != "addEdge")) {
		window.frame.changeForm("addEdge");
	}
}

/**
 * Object to hold an addChoice request
 */
function addChoiceRequest(number, choice) {
	this.__XMLclass = "addChoiceRequest";	
	this.number = number;
	this.choice = choice;
	this.id = sessionStorage['gameid'];
}
